package see.battle.test;

import see.battle.Const;
import see.battle.object.Ship;

import junit.framework.TestCase;

public class ShipTestCase extends TestCase {
  
  long _creationTime;
  long _currentTime;
  long _nextCurrentTime;
  float _shortMovement;
  float _longMovement;

	protected void setUp() throws Exception {
		super.setUp();
    _creationTime = Const.updateDelay * 10;
    _currentTime = Const.updateDelay * 20;
    _nextCurrentTime = Const.updateDelay * 40;
    _shortMovement = Const.shipSpeed * 10;
    _longMovement = Const.shipSpeed * 30;
	}
	
	public void testLeftShip() {
    Ship ship = new Ship(null, 1, Const.fromLeftToRightDirection, null, 
        _creationTime, _currentTime);
		assertEquals(ship.get_position(), Const.backgroundLeft - Const.shipWidth +
		    _shortMovement);
		ship.update(_nextCurrentTime);
		assertEquals(ship.get_position(), Const.backgroundLeft - Const.shipWidth +
        _longMovement);
	}
	
	public void testRightShip() {
    Ship ship = new Ship(null, 1, Const.fromRightToLeftDirection, null, 
        _creationTime, _currentTime);
    assertEquals(ship.get_position(), Const.backgroundRight - _shortMovement);
    ship.update(_nextCurrentTime);
    assertEquals(ship.get_position(), Const.backgroundRight - _longMovement);
	}
}

